var webpack = require('webpack');
var path = require('path');
var bower_dir = path.join(__dirname, 'bower_components');
var node_modules_dir = path.join(__dirname, 'node_modules');

var version = '1.1'
var config = {
  addVendor: function(name, path) {
    this.resolve.alias[name] = path;
    this.module.noParse.push(path);
  },
  entry: {
    '/js/app': ['./src/app.js','./src/img/test.jpg'],
    'user': './src/user.js',
  },
  output: {
    path: './build',
    filename: "bundle.[name]" + version + ".js"
  },
  vendor: {
    common: [
      'jquery'
    ]
  },
  // externals: {
  // require("jquery") is external and available
  //  on the global var jQuery
  //   'jquery': 'jQuery'
  // },
  resolve: {
    alias: {
      "createBrowserHistory": path.resolve(node_modules_dir, 'history/lib/createBrowserHistory'),
      "normalize.css": path.resolve(bower_dir, 'normalize-css/normalize.css'),
      "font-awesome.css": path.resolve(bower_dir, 'font-awesome/css/font-awesome.min.css'),
      "node-uuid": path.resolve(node_modules_dir, 'node-uuid/uuid'),
      "jquery": path.resolve(bower_dir, 'jquery/dist/jquery.min.js'),
    }
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  module: {
    noParse: ['./src/noparse/*'],
    loaders: [{
      test: /\.js$/,
      loaders: ["babel"],
      exclude: /node_modules/
    }, {
      test: /\.less$/,
      loader: "style!css!less"
    }, {
      test: /\.jpg|\.png$/,
      loader: "file-loader"
    }]
  }
};
module.exports = config;
